package com.hycas.array;
//冒泡排序
public class ArrayDemo04 {
    public static void main(String[] args) {
        int[] a={1,55,98,201,55,31,3,5,9};
        int[] t = socrt(a);
        System.out.println(t);
    }
//冒泡排序
    public static int[] socrt(int[] array) {
        int tmp = 0;//临时变量
        //外层循环 判断要走多少次
        for (int i = 0; i < array.length-1; i++) {
            //内层循环 比较判断两个数的大小
            for (int j = 0; j <array.length-1-i ; j++) {
                if(array[j]>array[j+1]){
                    tmp =array[j];
                    array[j] =array[j+1];
                    array[j+1]=tmp;
                }

            }

        }
        return array;
    }
}
